﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace ScarEngine
{
    public class PhysicsComponent : Component
    {
        /// <summary>
        /// Sets the mass of the physics object
        /// This will influence the objects movement
        /// This is not the weight of the object
        /// Weight = Mass * Gravity
        /// </summary>
        public float Mass;
        /// <summary>
        /// The Restitution of the physics object
        /// 2 = 200% force returned
        /// 1 = 100% force returned
        /// 0.5 = 50% force returned
        /// 0 = no force returned
        /// MAY BE ALL NON-NEGATIVE NUMBERS
        /// </summary>
        public float Restitution;
        /// <summary>
        /// Physics Rectangle
        /// Similar to normal rectangle but data is stored as floats and not integers.
        /// </summary>
        public PhysRectangle Rectangle;
        /// <summary>
        /// Sets the Collision list
        /// Objects in the same collision list will collide with eachother
        /// Collision lists are managed by the Physics Engine
        /// Collision List 0 = No collisions
        /// </summary>
        public int CollisionList;
        /// <summary>
        /// If the object is static then it will never move no matter how much force is applied.
        /// An objects restitution is still applied however.
        /// </summary>
        public bool Static;
        /// <summary>
        /// True = gravity
        /// </summary>
        public bool Gravity;

        public PhysicsComponent()
            : base()
        {
            MasterManager.PhysicsManager.RegisterPhysicsComponent(this);

            Mass = 1;
            Restitution = 1;
            Rectangle = new PhysRectangle(0, 0, 1, 1);
            CollisionList = 0;
            Gravity = false;
            Static = false;
        }


       

        #region Core
        public override void Delete()
        {
            base.Delete();
        }

        public override void Prerequisites()
        {
            if (Object.HasComponent<PositionalComponent>() == false)
            {
                Object.Add<PositionalComponent>("Position");
            }
            base.Prerequisites();
        }

        #endregion


    }
}